/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.maternity.classes.dao;

import br.com.maternity.classes.entity.AtendimentoExame;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 * @author Gattini
 */
public class AtendimentoExameDAO extends GenericDAO<AtendimentoExame> {

    private static AtendimentoExame instance = new AtendimentoExame();

    public AtendimentoExameDAO() {
        super(instance);
    }

    @Override
    public List<GenericDAOField> listFields() {
        List l = new ArrayList<GenericDAOField>();

        l.add(new GenericDAOField(
                "IdAtendimento", "setIdAtendimento", "getIdAtendimento", Integer.class, true, GenericDAOFieldPrimaryKey.NOTHING));
        l.add(new GenericDAOField(
                "IdExame", "setIdExame", "getIdExame", Integer.class, true, GenericDAOFieldPrimaryKey.NOTHING));
        l.add(new GenericDAOField(
                "DataSolicitacao", "setDataSolicitacao", "getDataSolicitacao", Date.class, true, GenericDAOFieldPrimaryKey.NOTHING));
        l.add(new GenericDAOField(
                "Resultado", "setResultado", "getResultado", String.class, false, null));

        return l;
    }

    @Override
    public String tableName() {
        return "AtendimentoExame";
    }

    public List<AtendimentoExame> selectByAtendimento(Integer id) {
        try {
            String query = "SELECT * FROM " + tableName() + " WHERE IdAtendimento = ? ORDER BY DataSolicitacao";
            PreparedStatement ps = getPreparedStatement(query);
            ps.setInt(1, id);
            return selectList(ps);
        } catch (Exception ex) {
            return new ArrayList<AtendimentoExame>();
        }

    }
}
